Tegra: memctrl: clean MC INT status before exit to bootloader
authorHarvey Hsieh <[email protected]>
Mon, 21 Aug 2017 07:01:53 +0000 (15:01 +0800)
committerVarun Wadekar <[email protected]>
Fri, 18 Jan 2019 17:21:51 +0000 (09:21 -0800)
This patch cleans the Memory controller's interrupt status
register, before exiting to the non-secure world during
cold boot. This is required as we observed that the MC's
arbitration bit is set before exiting the secure world.

Change-Id: Iacd01994d03b3b9cbd7b8a57fe7ab5b04e607a9f
Signed-off-by: Harvey Hsieh <[email protected]>
plat/nvidia/tegra/common/drivers/memctrl/memctrl_v1.c
plat/nvidia/tegra/common/drivers/memctrl/memctrl_v2.c
plat/nvidia/tegra/common/tegra_bl31_setup.c
plat/nvidia/tegra/include/drivers/memctrl.h
plat/nvidia/tegra/include/t132/tegra_def.h
plat/nvidia/tegra/include/t210/tegra_def.h

index 27ad563bcd6426c1ea9be6831ddb37dcd2d65912..92fa273b54c66f1eed2d6accb2d7ddacef3afa86 100644 (file)
@@ -209,3 +209,16 @@ void tegra_memctrl_disable_ahb_redirection(void)
        /* lock the aperture registers */
        tegra_mc_write_32(MC_IRAM_REG_CTRL, MC_DISABLE_IRAM_CFG_WRITES);
 }
+
+void tegra_memctrl_clear_pending_interrupts(void)
+{
+       uint32_t mcerr;
+
+       /* check if there are any pending interrupts */
+       mcerr = mmio_read_32(TEGRA_MC_BASE + MC_INTSTATUS);
+
+       if (mcerr != (uint32_t)0U) { /* should not see error here */
+               WARN("MC_INTSTATUS = 0x%x (should be zero)\n", mcerr);
+               mmio_write_32((TEGRA_MC_BASE + MC_INTSTATUS),  mcerr);
+       }
+}
index cfa95818e9352c64122b624b1b31c289870bf1fa..1b221c2f6157954ded9935e257fea1d9d22e0175 100644 (file)
@@ -712,3 +712,8 @@ void tegra_memctrl_disable_ahb_redirection(void)
 {
        ; /* do nothing */
 }
+
+void tegra_memctrl_clear_pending_interrupts(void)
+{
+       ; /* do nothing */
+}
index 30ff0a38d47414abf1639dcb34ec909b8074b8aa..afb10fef47619a0334d0610403eee0f7a88e5962 100644 (file)
@@ -341,6 +341,15 @@ void bl31_platform_setup(void)
  ******************************************************************************/
 void bl31_plat_runtime_setup(void)
 {
+       /*
+        * During cold boot, it is observed that the arbitration
+        * bit is set in the Memory controller leading to false
+        * error interrupts in the non-secure world. To avoid
+        * this, clean the interrupt status register before
+        * booting into the non-secure world
+        */
+       tegra_memctrl_clear_pending_interrupts();
+
        /*
         * During boot, USB3 and flash media (SDMMC/SATA) devices need
         * access to IRAM. Because these clients connect to the MC and
index 17427cbec959f20d78e570fde0ba46b4a06a7930..d5ef60d0ca3393d43bdeaab6f4455eccd67c5b42 100644 (file)
@@ -13,5 +13,6 @@ void tegra_memctrl_tzdram_setup(uint64_t phys_base, uint32_t size_in_bytes);
 void tegra_memctrl_tzram_setup(uint64_t phys_base, uint32_t size_in_bytes);
 void tegra_memctrl_videomem_setup(uint64_t phys_base, uint32_t size_in_bytes);
 void tegra_memctrl_disable_ahb_redirection(void);
+void tegra_memctrl_clear_pending_interrupts(void);
 
 #endif /* MEMCTRL_H */
index 1f58caabb5206beb841bc390055e44a601a9e4e1..fd75fbce6fafa792d101c467f6fd0e63192e2bd7 100644 (file)
@@ -83,6 +83,9 @@
  ******************************************************************************/
 #define TEGRA_MC_BASE                  U(0x70019000)
 
+/* Memory Controller Interrupt Status */
+#define MC_INTSTATUS                   0x00U
+
 /* TZDRAM carveout configuration registers */
 #define MC_SECURITY_CFG0_0             U(0x70)
 #define MC_SECURITY_CFG1_0             U(0x74)
index b16a129daa7b219c7cbc90600d2d3ad0ca88f59a..75919e11e4c5441ea969c99404f941aa0b326433 100644 (file)
  ******************************************************************************/
 #define TEGRA_MC_BASE                  U(0x70019000)
 
+/* Memory Controller Interrupt Status */
+#define MC_INTSTATUS                   0x00U
+
 /* TZDRAM carveout configuration registers */
 #define MC_SECURITY_CFG0_0             U(0x70)
 #define MC_SECURITY_CFG1_0             U(0x74)